﻿using InstallWizard.DAL;
using InstallWizard.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace InstallWizard
{
    public partial class Page2 : Form
    {
        string configFile = "wizard.config";
        public Page2()
        {
            InitializeComponent();
        }
        #region 单独不现实窗体关闭按钮
        private const int CP_NOCLOSE_BUTTON = 0x200;
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams myCp = base.CreateParams;
                myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON;
                return myCp;
            }
        }
        #endregion
        private void Page2_Load(object sender, EventArgs e)
        {
            
        }
        private void Page2_Shown(object sender, EventArgs e)
        {
            AppInfo appInfo = FileIO.ReadConfigFile(configFile, out List<AppFileInfo> flist);
            Text = $"{appInfo.AppName} {appInfo.AppVer}安装向导";
            txtLicense.Text = appInfo.GetLicense();
            lbComment.Text = $"在安装 { appInfo.AppName} {appInfo.AppVer} 之前，请检阅授权条款。";
            lbIfAccept.Text = $"如果你接受协议条款，单击[我同意(I)]继续安装。必须接受协议才能安装{appInfo.AppName} {appInfo.AppVer}。";
        }
        private void BtnPrev_Click(object sender, EventArgs e)
        {
            this.Hide();
            Form[] pages = Tag as Form[];
            pages[0].Show();
        }

        private void BtnNext_Click(object sender, EventArgs e)
        {
            this.Hide();
            Form[] pages = Tag as Form[];
            pages[2].Show();
        }

        private void BtnCancel_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void TxtLicense_TextChanged(object sender, EventArgs e)
        {

        }

        private void Page2_FormClosed(object sender, FormClosedEventArgs e)
        {
            //Application.Exit();
        }

      
    }
}
